package models

import "gorm.io/gorm"

type User struct {
	gorm.Model
	Models   string `gorm:"type:varchar(20);unique;comment:<手机号>"`
	Password string `gorm:"type:varchar(32);comment:<密码>"`
}

func (u *User) GetUserByAccount() error {
	return DB.Where("models = ?", u.Models).Limit(1).Find(u).Error
}

func (u *User) Register() error {
	return DB.Create(&u).Error
}

func (u *User) GetUserById() error {
	return DB.Where("id = ?", u.ID).Limit(1).Find(u).Error
}
